package com.cbts.entity;

import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

/**
 * ExchangeRecord entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "exchange_record", catalog = "cbts")
public class ExchangeRecord implements java.io.Serializable {

	// Fields

	private ExchangeRecordId id;
	private Gift gift;
	private UserInfo userInfo;
	private Double points;
	private String exchangeStatus;
	private Integer number;

	// Constructors

	/** default constructor */
	public ExchangeRecord() {
		points=0.0;
		exchangeStatus="否";
		number = 0;
	}

	/** full constructor */
	public ExchangeRecord(ExchangeRecordId id, Gift gift, UserInfo userInfo,
			Double points, String exchangeStatus, Integer number) {
		this.id = id;
		this.gift = gift;
		this.userInfo = userInfo;
		this.points = points;
		this.exchangeStatus = exchangeStatus;
		this.number = number;
	}

	// Property accessors
	@EmbeddedId
	@AttributeOverrides( {
			@AttributeOverride(name = "exchangeTime", column = @Column(name = "exchangeTime", nullable = false, length = 19)),
			@AttributeOverride(name = "userid", column = @Column(name = "userid", nullable = false, length = 15)) })
	public ExchangeRecordId getId() {
		return this.id;
	}

	public void setId(ExchangeRecordId id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "giftId", nullable = false)
	public Gift getGift() {
		return this.gift;
	}

	public void setGift(Gift gift) {
		this.gift = gift;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "userid", nullable = false, insertable = false, updatable = false)
	public UserInfo getUserInfo() {
		return this.userInfo;
	}

	public void setUserInfo(UserInfo userInfo) {
		this.userInfo = userInfo;
	}

	@Column(name = "points", nullable = false, precision = 11)
	public Double getPoints() {
		return this.points;
	}

	public void setPoints(Double points) {
		this.points = points;
	}

	@Column(name = "exchangeStatus", nullable = false, length = 2)
	public String getExchangeStatus() {
		return this.exchangeStatus;
	}

	public void setExchangeStatus(String exchangeStatus) {
		this.exchangeStatus = exchangeStatus;
	}

	@Column(name = "number", nullable = false)
	public Integer getNumber() {
		return this.number;
	}

	public void setNumber(Integer number) {
		this.number = number;
	}

}